home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Toolbox / Sys7 popUpCDEF / SimplePopupCDEF.c next >
Encoding:
C/C++ Source or Header  |  1992-11-02  |  21.3 KB  |  586 lines  |  [TEXT/MPS ]

  1. /* A small sample of how to use the popupCDEF under System 7 */
  2. /* Pretty straighforward */
  3. /* Look at the Rez file to see how to set up the */
  4. /* different types of PopUps shown here. */
  5. /* One other thing of importance..... */
  6.  
  7. /* A menu created with the popupCDEF is NOT always included in the */
  8. /* menu list!  The CDEF can (and will) remove it from the menu list  */
  9. /* when it needs to.  That means that you CANNOT */
  10. /* call GetMHandle(...) to get a handle to a popupCDEF menu handle. */
  11. /* Look at the fuction here called 
  12.     GetPopUpMenuHandle
  13.    to see how to do this the correct way. */
  14. /* Of course, Copyright 1991-1992, Apple Computer Inc. */
  15. /* C.K. Haun */
  16. /* Apple Developer Techniocal Support */
  17. #include "SimplePopupCDEF.h"
  18.  
  19.  
  20. typedef struct popupPrivateData {
  21. MenuHandle mHandle; /* the popup menu handle */
  22. short mID;          /* the popup menu ID */
  23. /* after these two public fields is the mPrivate private data, */
  24. /* which may be any old size and should not be messed with */
  25. }popupPrivateData;
  26. typedef popupPrivateData *popupPrivateDataPtr,**popupPrivateDataHdl;
  27.  
  28.  
  29.  
  30. /* prototypes */
  31.  
  32. void InitalizeApp(void);
  33. void DoDiskEvents(long dinfo);                              /* hi word is error code, lo word is drive number */
  34. void DrawMain(WindowPtr drawIt);
  35. Boolean DoSelected(long val);
  36. void SizeMain(WindowPtr theWindow);
  37. void InitAEStuff(void);
  38. void DoHighLevel(EventRecord *AERecord);
  39. void DoDaCall(MenuHandle themenu, long theit);
  40. void DoDocumentClick(WindowPtr theWindow);
  41.  
  42. pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  43. pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  44. pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  45. pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  46.  
  47. void SampleHelpDialog(void);
  48.  
  49. WindowPtr AddNewWindow(short theID);
  50. MenuHandle GetPopUpMenuHandle(ControlHandle thisControl);
  51. void NilProc(void);
  52. /* one external */
  53. extern void _DataInit();                                    /* this is the C initialization code */
  54.  
  55. /* globals */
  56. Boolean gQuit, gInBackground;
  57. unsigned long gMySleep;
  58. ProcessSerialNumber gOurSN;
  59. short gHelpItem;
  60.  
  61.  
  62. #pragma segment Main
  63. main()
  64. {
  65.     EventRecord myEventRecord;
  66.     WindowPtr twindow;
  67.     short fHit;
  68.     windowCHandle tempWCH;
  69.  
  70.     UnloadSeg((Ptr)_DataInit);                              /* throw out setup code */
  71.     InitalizeApp();
  72.     UnloadSeg((Ptr)InitalizeApp);                           /* get rid of my initialization code */
  73.     do {
  74.         
  75.          WaitNextEvent(everyEvent, &myEventRecord, gMySleep, nil);
  76.         switch (myEventRecord.what) {
  77.             case nullEvent:
  78.                 /* no nul processing in this sample */
  79.                 break;
  80.             case updateEvt:
  81.             /* always check to see if it's my window */
  82.             /* this may not seem necessary under 7.0, where it's unlikely or impossible for */
  83.             /* a DA to be in your layer, but there are others  */
  84.             /* who can stick themselves into your window list, */
  85.             /* BalloonWriter comes quickly to mind */
  86.                 tempWCH = (windowCHandle)GetWRefCon((WindowPtr)myEventRecord.message);
  87.                 (ProcPtr)((*tempWCH)->drawMe)((WindowPtr)myEventRecord.message);
  88.                 break;
  89.             case mouseDown:
  90.                 /* first see where the hit was */
  91.                 fHit = FindWindow(myEventRecord.where, &twindow);
  92.                 switch (fHit) {
  93.                 Rect limitRect;
  94.                 Str255 tempString;    
  95.                 long back;
  96.                     case inDesk:                            /* if they hit in desk, then the process manager */
  97.                         break;                              /* will switch us out, we don't need to do anything */
  98.                     case inMenuBar:
  99.                         DoSelected(MenuSelect(myEventRecord.where));
  100.                         break;
  101.                         
  102.                     case inSysWindow:
  103.                         /* pass to the system */
  104.                         SystemClick(&myEventRecord, twindow);
  105.                         break;
  106.                     case inContent:
  107.                         /* Handle content and control clicks here */
  108.                 if (FrontWindow()) {           /* don't do this unless we have a window open, silly */
  109.                             windowCHandle clicker;
  110.                             clicker = (windowCHandle)GetWRefCon(twindow);
  111.                             /* jump to the content function stored for this window */
  112.                             HLock((Handle)clicker);     /* lock it down so things don't get stupid */
  113.                             (ProcPtr)((*clicker)->clickMe)(twindow);
  114.                             HUnlock((Handle)clicker);       /* all done */
  115.                         }
  116.  
  117.                         break;
  118.                     case inDrag:
  119.                             DragWindow(twindow, myEventRecord.where, &qd.screenBits.bounds);
  120.                         break;
  121.                     case inGrow:
  122.                         /* Call GrowWindow here if you have a grow box */
  123.                      SetPort(twindow);
  124.                         limitRect = qd.screenBits.bounds;
  125.                         limitRect.top = kMinHeight;
  126.                         GetWTitle(twindow, tempString);
  127.                         /* I'm not letting the user shrink the window so */
  128.                         /* small that the title is truncated */
  129.                         limitRect.left = StringWidth(tempString) + 120;
  130.                         back = GrowWindow(twindow,myEventRecord.where, &limitRect);
  131.                         
  132.                         if (back) {windowCHandle tempWCH = (windowCHandle)GetWRefCon(twindow);
  133.                             Rect sizeRect = ((WindowPtr)twindow)->portRect;                            
  134.                             InvalRect(&sizeRect);
  135.                             sizeRect.top = sizeRect.bottom - 16;
  136.                             sizeRect.left = sizeRect.right - 16;
  137.                             EraseRect(&sizeRect);
  138.                             InvalRect(&sizeRect);                            
  139.                             SizeWindow(twindow, back & 0xffff, back >> 16, true);
  140.                             (ProcPtr)((*tempWCH)->sizeMe)(twindow);                            
  141.                         }
  142.                        
  143.                         InvalRect(&twindow->portRect);
  144.  
  145.                         break;
  146.                     case inGoAway:
  147.                         /* Click in Close box */
  148.                 if (TrackGoAway(twindow, myEventRecord.where))
  149.                     (ProcPtr)((*(windowCHandle)((WindowPeek)twindow)->refCon)->closeMe)(twindow);
  150.  
  151.                         break;
  152.                                         case inZoomIn:
  153.                     case inZoomOut:
  154.                     if (TrackBox(twindow, myEventRecord.where, fHit)) {windowCHandle tempWCH = (windowCHandle)GetWRefCon(twindow);
  155.                             SetPort(twindow);                            
  156.                             InvalRect(&twindow->portRect);                        
  157.                             
  158.                             ZoomWindow(twindow, fHit, true);
  159.                         (ProcPtr)((*tempWCH)->sizeMe)(twindow);
  160.                         }
  161.     
  162.                         
  163.                 }
  164.             case mouseUp:
  165.                 /* don't care */
  166.                 break;
  167.                 /* same action for key or auto key */
  168.             case keyDown:
  169.             case autoKey:
  170.                 if (myEventRecord.modifiers & cmdKey)
  171.                     DoSelected(MenuKey(myEventRecord.message & charCodeMask));
  172.                 break;
  173.             case keyUp:
  174.                 /* don't care */
  175.                 break;
  176.             case diskEvt:
  177.                 /* I don't do anything special for disk events, this just passes them */
  178.                 /* to a function that checks for an error on the mount */
  179.                 DoDiskEvents(myEventRecord.message);
  180.                 break;
  181.             case activateEvt:
  182.                 if (myEventRecord.modifiers & activeFlag){
  183.                 tempWCH = (windowCHandle)GetWRefCon((WindowPtr)myEventRecord.message);
  184.                 (ProcPtr)((*tempWCH)->drawMe)((WindowPtr)myEventRecord.message);
  185.                     }
  186.                 break;
  187.             case networkEvt:
  188.                 /* don't care */
  189.                 break;
  190.             case driverEvt:
  191.                 /* don't care */
  192.                 break;
  193.             case app4Evt:
  194.                 switch ((myEventRecord.message >> 24) & 0x0FF) {     /* high byte of message */
  195.                     case suspendResumeMessage:              /* suspend/resume is also an activate/deactivate */
  196.                         gInBackground = (myEventRecord.message & kResumeMask) == 0;
  197.                         if(!gInBackground)InitCursor();
  198.                         break;
  199.                 }
  200.                 break;
  201.             default:
  202.                 break;
  203.                 /* This dispatches high level events (AppleEvents, for example) */
  204.                 /* to our dispatch routine.  This is NEW in the event loop for */
  205.                 /* System 7 */
  206.             case kHighLevelEvent:
  207.                 DoHighLevel(&myEventRecord);
  208.                 break;
  209.                 
  210.         }
  211.     }
  212.             while (gQuit != true);
  213.     
  214. }
  215.  
  216. /* DoDaCall opens the requested DA.  It's here as a seperate routine if you'd */
  217. /* like to perform some action or just know when a DA is opened in your */
  218. /* layer.  Can be handy to track memory problems when a DA is opened */
  219. /* with an Option-open */
  220. void DoDaCall(MenuHandle themenu, long theit)
  221. {
  222.     long qq;
  223.     char DAname[255];
  224.     GetItem(themenu, theit, &DAname);
  225.     qq = OpenDeskAcc(DAname);
  226. }
  227.  
  228. /* end DoDaCall */
  229.  
  230. /* DoDiskEvents just checks the error code from the disk mount, */
  231. /* and puts up the 'Format' dialog (through DIBadMount) if need be */
  232. /* You can do much more here if you care about what disks are */
  233. /* in the drive */
  234. void DoDiskEvents(long dinfo)                               /* hi word is error code, lo word is drive number */
  235. {
  236.     short hival, loval, tommy;
  237.     Point fredpoint =  {
  238.         40, 40
  239.     };
  240.     hival = HiWord(dinfo);
  241.     loval = LoWord(dinfo);
  242.     if (hival != noErr)                                     /* something happened */ {
  243.         tommy = DIBadMount(fredpoint, dinfo);
  244.     }
  245. }
  246.  
  247. /* draws my window.  Pretty simple */
  248. void DrawMain(WindowPtr drawIt)
  249. {
  250.     RgnHandle tempRgn;
  251.     Rect scratchRect;
  252.     BeginUpdate(drawIt);
  253.     SetPort(drawIt);
  254.     EraseRect(&drawIt->portRect);
  255.     scratchRect = drawIt->portRect;
  256.     scratchRect.top = scratchRect.bottom - 15;
  257.     scratchRect.left = scratchRect.right - 15;
  258.     tempRgn = NewRgn();
  259.     GetClip(tempRgn);
  260.     ClipRect(&scratchRect);
  261.     DrawGrowIcon(drawIt);
  262.     SetClip(tempRgn);
  263.     DrawControls(drawIt);
  264.     DisposeRgn(tempRgn);
  265.  
  266.     
  267.     EndUpdate(drawIt);
  268. }
  269.  
  270. /* my menu action taker.  It returns a Boolean which I usually ignore, but it */
  271. /* mught be handy someday */
  272. /* I usually use it in an application to determine if a keystroke was accepted */
  273. /* by a menu or whether it should be passed along to any other key acceptors */
  274. Boolean DoSelected(long val)
  275. {
  276.     short loval, hival;
  277.     Boolean returnVal = false;
  278.     loval = LoWord(val);
  279.     hival = HiWord(val);
  280.     
  281.     switch (hival) {                                        /* switch off the menu number selected */
  282.         case kAppleMenu:                                    /* Apple menu */
  283.             if (loval != 1) {                               /* if this was not About, it's a DA */
  284.                 DoDaCall(GetMHandle(kAppleMenu), loval);
  285.             } else {
  286.                 Alert(kAboutBox, nil);                      /* do about box */
  287.             }
  288.             returnVal = true;
  289.             break;
  290.         case kFileMenu:                                     /* File menu */
  291.             switch (loval) {
  292.                 case kQuitItem:
  293.                     gQuit = true;                           /* only  item */
  294.                     returnVal = true;
  295.                     break;
  296.                 default:
  297.                     break;
  298.             }
  299.             break;
  300.         case kEditMenu:
  301.             /* edit menu junk */
  302.             /* don't care */
  303.             switch(loval){
  304.             default:
  305.             break;}
  306.             break;
  307.         case kToolsMenu:
  308.             /* add all your test stuff here */
  309.             switch(loval){
  310.             default:
  311.             break;}
  312.  
  313.             break;
  314.         case kHMHelpMenuID:                                 /* Defined in Balloons.h */
  315.             /* I only care about this item.  If anything else is returned here, I don't know what */
  316.             /* it is, so I leave it alone.  Remember, the Help Manager chapter says that */
  317.             /* Apple reserves the right to add and change things in the Help menu */
  318.             if (loval == gHelpItem)
  319.                 SampleHelpDialog();
  320.             break;
  321.             
  322.     }
  323.     HiliteMenu(0);
  324.     return(returnVal);
  325. }
  326.  
  327.  
  328. void DoDocumentClick(WindowPtr theWindow)
  329. {Point thePoint;
  330. ControlHandle theControl;
  331. GetMouse(&thePoint);
  332. if(FindControl(thePoint, theWindow, &theControl)){
  333.     /* ••• NOTE! */
  334.     /* You MUST pass  '(ProcPtr) -1' to TrackControl to have the */
  335.     /* popupCDEF menus automatically popped and tracked for you! */
  336.     if(TrackControl(theControl, thePoint,(ProcPtr) -1)){
  337.     Str255 myString;
  338.     MenuHandle selectedMenu;
  339.     Rect clearIt;
  340.     SetRect(&clearIt,0,0,theWindow->portRect.right,20);
  341.     EraseRect(&clearIt);
  342.     /* if you selected something, I'll tell you about it */
  343.     
  344.     MoveTo(5,16);
  345.     GetIndString(&myString,kGeneralStrings,kSayLastItem);
  346.     DrawString(myString);
  347.     selectedMenu = GetPopUpMenuHandle(theControl);
  348.     GetItem(selectedMenu, GetCtlValue(theControl),myString);
  349.     DrawString(myString);
  350.     }
  351.     }
  352.  
  353. }
  354.  
  355.  
  356. /* InitAEStuff installs my appleevent handlers */
  357. void InitAEStuff(void)
  358. {
  359.     AEinstalls HandlersToInstall[] =  { {
  360.             kCoreEventClass, kAEOpenApplication, AEOpenHandler
  361.         },  {
  362.             kCoreEventClass, kAEOpenDocuments, AEOpenDocHandler
  363.         },  {
  364.             kCoreEventClass, kAEQuitApplication, AEQuitHandler
  365.         },  {
  366.             kCoreEventClass, kAEPrintDocuments, AEPrintHandler
  367.         }, 
  368.         /* The above are the four required AppleEvents. */
  369.         
  370.     };
  371.     
  372.     OSErr aevtErr = noErr;
  373.     long aLong = 0;
  374.     Boolean gHasAppleEvents = false;
  375.     /* Check this machine for AppleEvents.  If they are not here (ie not 7.0)
  376.     *   then we exit */
  377.     gHasAppleEvents = (Gestalt(gestaltAppleEventsAttr, &aLong) == noErr);
  378.     /* The following series of calls installs all our AppleEvent Handlers.
  379.     *   These handlers are added to the application event handler list that 
  380.     *   the AppleEvent manager maintains.  So, whenever an AppleEvent happens
  381.     *   and we call AEProcessEvent, the AppleEvent manager will check our
  382.     *   list of handlers and dispatch to it if there is one.
  383.     */
  384.     if (gHasAppleEvents) {
  385.         register qq;
  386.         for (qq = 0; qq < ((sizeof(HandlersToInstall) / sizeof(AEinstalls))); qq++) {
  387.             aevtErr = AEInstallEventHandler(HandlersToInstall[qq].theClass, HandlersToInstall[qq].theEvent,
  388.                                             HandlersToInstall[qq].theProc, 0, false);
  389.             if (aevtErr) {
  390.                 ExitToShell();                              /* just fail, baby */
  391.             }
  392.         }
  393.     } else {
  394.         ExitToShell();
  395.     }
  396. }
  397.  
  398. /* end InitAEStuff */
  399. /* I'm not doing error handling in this sample for clarities sake, you should. Hah, */
  400. /* easy for me to say, huh? */
  401. void DoHighLevel(EventRecord *AERecord)
  402. {OSErr myErr;
  403.     myErr=AEProcessAppleEvent(AERecord);
  404.     
  405. }
  406.  
  407. /* end DoHighLevel */
  408.  
  409. /* This is the standard Open Application event.  */
  410. pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  411. {WindowPtr myWindow; 
  412.  
  413. #pragma unused (messagein,reply,refIn)
  414.     /* we of course don't do anything here in this simple app */
  415.     /* except open our window */
  416.     myWindow = AddNewWindow(kDocWindowResID);
  417.     
  418.     return(noErr);
  419. }
  420.  
  421. /* end AEOpenHandler */
  422.  
  423. /* Open Doc, opens our documents.  Remember, this can happen at application start AND */
  424. /* anytime else.  If your app is up and running and the user goes to the desktop, hilites one */
  425. /* of your files, and double-clicks or selects Open from the finder File menu this event */
  426. /* handler will get called. Which means you don't do any initialization of globals here, or */
  427. /* anything else except open then doc.  */
  428. /* SO-- Do NOT assume that you are at app start time in this */
  429. /* routine, or bad things will surely happen to you. */
  430.  
  431. pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  432. {
  433. #pragma unused (messagein,refIn,reply)
  434.     /* we of course don't do anything here */
  435.     return(errAEEventNotHandled);                           /* we have no docs, so no odoc events should come to us */
  436. }
  437.  
  438. pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  439. {                                                           /* no printing handler in yet, so we'll ignore this */
  440.     /* the operation is functionally identical to the ODOC event, with the additon */
  441.     /* of calling your print routine.  */
  442. #pragma unused (messagein,refIn,reply)
  443.     /* we of course don't do anything here */
  444.     return(errAEEventNotHandled);                           /* we have no docs, so no pdoc events should come to us */
  445. }
  446.  
  447. /* Standard Quit event handler, to handle a Quit event from the Finder, for example.  */
  448. /* ••••• DO NOT CALL EXITTOSHELL HERE ••••• or you will never have a happy life.  */
  449. /* OK, it's a few months after I wrote that comment, and I've seen a lot of code */
  450. /* come through DTS that calls ExitToShell from quit handlers.  Let me explain... */
  451. /* When an AppleEvent Handler is called (like this quit handler) you are ALMOST */
  452. /* 100% in your application world.  A5 is right, you can call any toolbox function, */
  453. /* you can call your own routines, everything _seems_ like you are in complete  */
  454. /* control.  Well, almost but not quite.  The routine has been dispatch to from the */
  455. /* AppleEvent Manager's space, so you _must_ return to that at some point! */
  456. /* Which is why you can't call ETS from here.  When you call ExitToShell from an */
  457. /* AE Handler, the most likely thing that happens is the FInder quits, and your  */
  458. /* application keeps running.  Which ain't what you want, y'know? */
  459. /* so, DON'T CALL EXITTOSHELL FROM AN APPLEEVENT HANDLER!!!!!!!!!!!!!! */
  460. pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  461. {
  462. #pragma unused (messagein,refIn,reply)
  463.     gQuit = true;
  464.     return(noErr);
  465. }
  466.  
  467.  
  468.  
  469. /* This is my sample help dialog.  Does not do anything, expand as you need */
  470. void SampleHelpDialog(void)
  471. {
  472.     DialogPtr tdial = GetNewDialog(kSampHelp, nil, (WindowPtr)-1);
  473.     short itemhit = 0;
  474.     while (itemhit != 1) {
  475.         ModalDialog((ModalFilterProcPtr)nil, &itemhit);
  476.     }
  477.     DisposDialog(tdial);
  478. }
  479.  
  480. #pragma segment Initialize
  481. void InitalizeApp(void)
  482. {
  483.     Handle myMenu;
  484.     MenuHandle helpHandle,appleMenuHandle;
  485.     StringHandle helpString;
  486.     short count;
  487.     long vers;
  488.     MaxApplZone();
  489.     InitGraf((Ptr)&qd.thePort);
  490.     InitFonts();
  491.     InitWindows();
  492.     InitMenus();
  493.     TEInit();
  494.     InitDialogs(nil);
  495.     InitCursor();
  496.     /* Check system version */
  497.     Gestalt(gestaltSystemVersion, &vers);
  498.     vers = (vers >> 8) & 0xf;                               /* shift result over and mask out major version number */
  499.     if (vers < 7) {
  500.         StopAlert(kBadSystem, nil);
  501.         ExitToShell();
  502.     }
  503.     InitAEStuff();
  504.     /* set up my menu junk */
  505.     myMenu = GetNewMBar(kMBarID);
  506.     SetMenuBar(myMenu);
  507.     appleMenuHandle = GetMHandle(kAppleMenu);
  508.     AddResMenu(appleMenuHandle, 'DRVR');
  509.  
  510.     /* now install my Help menu item in the Help Manager's menu */
  511.     HMGetHelpMenuHandle(&helpHandle);                       /* Get the Hlpe menu handle */
  512.     count = CountMItems(helpHandle);                        /* How many items are there? */
  513.     helpString = GetString(kHelpString);                    /* get my help string */
  514.     DetachResource(helpString);                             /* detach it */
  515.     HNoPurge(helpString);
  516.     MoveHHi((Handle)helpString);
  517.     HLock((Handle)helpString);
  518.     InsMenuItem(helpHandle, (Ptr)*helpString, count + 1);       /* insert my item in the Help menu */
  519.     gHelpItem = CountMItems(helpHandle);                    /* The number of the item */
  520.     
  521.        
  522.     DrawMenuBar();
  523.     GetCurrentProcess(&gOurSN);                             /* Get our process serial number for later use, if needed */
  524.     
  525. }
  526.  
  527.  
  528. #pragma segment Main
  529. WindowPtr AddNewWindow(short theID)
  530. {
  531.     windowCHandle setControls;
  532.     WindowPtr tempWP;
  533.     short cnt = 0;
  534.     Str31 wtitle;
  535.     tempWP = GetNewWindow(theID, 0, (WindowPtr)-1);        /* get a new window */
  536.     SetPort(tempWP);
  537.     ((WindowPeek)tempWP)->windowKind = kMyDocumentWindow;     /* mark it as my document window */
  538.     setControls = (windowCHandle)NewHandleClear(sizeof(windowControl));       /* add our control structure to it */
  539.     SetWRefCon(tempWP,(long)setControls);    /* stop stuffing refCon directly <ckh 1.0.3> */
  540.     HLock((Handle)setControls);                             /* lock it down while we fill it*/
  541.     
  542.     /* add pointers to our procedures for drawing, saving, and closing */
  543.     /* This way, all I need is one dispatch point for drawing, closing */
  544.     /* or whatever, I don't have to case off the window kind to go to the  */
  545.     /* correct routine.  Kinda like object-oriented programming, but I won't */
  546.     /* admit that. */
  547.     (*setControls)->drawMe = (ProcPtr)DrawMain;
  548.     (*setControls)->clickMe = (ProcPtr)DoDocumentClick;
  549.     (*setControls)->sizeMe = (ProcPtr)SizeMain;
  550.     (*setControls)->generalData = NewHandle(0);
  551.         GetNewControl(128,tempWP);
  552.         GetNewControl(129,tempWP);
  553.         GetNewControl(130,tempWP);
  554.         GetNewControl(131,tempWP);
  555.  
  556.  
  557.  
  558. return(tempWP);
  559. }
  560.  
  561. void SizeMain(WindowPtr theWindow)
  562. {
  563. WindowPtr tempWP;
  564. GetPort(&tempWP);
  565. InvalRect(&theWindow->portRect);
  566. SetPort(tempWP);
  567. }
  568.  
  569. void NilProc(void)
  570. {
  571.  
  572. }
  573.  
  574.  
  575.  
  576. /* Since we can't call GetMHandle to access the menu handle, we have to  */
  577. /* look at the data stored in the control record */
  578. MenuHandle GetPopUpMenuHandle(ControlHandle thisControl)
  579. {
  580. popupPrivateDataHdl theMenuData = (popupPrivateDataHdl)(*thisControl)->contrlData;
  581. return((*theMenuData)->mHandle);
  582. }
  583.  
  584.  
  585.  
  586.